from django.shortcuts import render
from django.views import View
from django.utils import timezone
# Create your views here.

class TempView(View):

    def get(self, request):
        data = {
            'name': '黑马程序员',
            'alist': [1, 2, 3],
            'adict': {'age': 12, 'sex': 1},
            'a': 40,

            'ahtml': '<h1>大标题</h1>',
            'nowdate': timezone.now()

        }

        # return render(request, 'index.html', context='此参数必须传入字典')
        return render(request, 'index.html', context=data)



class TempBaseView(View):

    def get(self, request):
        return render(request, 'base.html')

class TempChildView(View):

    def get(self, request):
        return render(request, 'child.html')


class Jinja2View(View):

    def get(self, request):
        data = {
            'alist': ['a', 'b', 'c'],
            'abc': '123'
        }
        return render(request, 'jinja2_test.html', data)